package android_design_mode.chapter04_prototype;

import java.util.ArrayList;
import java.util.List;

/**
 * 原型模式
 */
public class WorkDocument implements Cloneable {

    private String mText;

    private List<String> mImages = new ArrayList<>();


    public WorkDocument() {
        System.out.println("-----------WorkDocument  构造函数：-----------");
    }

    @Override
    protected WorkDocument clone() {
        try {
            WorkDocument doc = (WorkDocument) super.clone();
            doc.mText = this.mText;
            doc.mImages = this.mImages;
            return doc;
        } catch (Exception e) {
        }
        return null;
    }

    public String getmText() {
        return mText;
    }

    public void setmText(String mText) {
        this.mText = mText;
    }

    public List<String> getmImages() {
        return mImages;
    }

    public void setmImages(List<String> mImages) {
        this.mImages = mImages;
    }

    public void addImages(String image) {
        if (mImages != null) {
            mImages.add(image);
        }
    }


    public void showDocument() {
        System.out.println("-----------Work Content ： Start-----------");
        System.out.println("Text : " + mText);
        System.out.println("Image List:");

        for (String image : mImages) {
            System.out.println("image name : " + image);
        }

        System.out.println("-----------Work Content ： End -----------");

    }
}
